import React from 'react'
import About from "./pages/About"
import Home from "./pages/Home"
import { Link, NavLink, Routes, Route, Navigate } from "react-router-dom"

export default function App() {
  return (
    <div>
      <div className="row">
        <div className="col-xs-8 col-md-8 col-lg-8 offset-xs-2 offset-md-2 offset-lg-2">
          <div className="page-header"><h2>React Router Demo</h2></div>
        </div>
      </div>
      <div className="row">
        <div className="col-xs-2 col-md-2 col-lg-2 offset-xs-2 offset-md-2 offset-lg-2">
          <div className="list-group">
            {/* 路由链接 */}
            <NavLink className="list-group-item" to="/about">About</NavLink>
            <NavLink className="list-group-item" to="/home">Home</NavLink>

            {/* 在React中靠路由链接实现切换组件--编写路由链接 */}
            {/* <BrowserRouter> */}
            {/* <Link className="list-group-item" to="/about">About</Link>
            <Link className="list-group-item" to="/home">Home</Link> */}
            {/* </BrowserRouter> */}
          </div>
        </div>
        <div className="col-xs-6 col-md-6 col-lg-6 col-xs-offset-2 col-md-offset-2 col-lg-offset-2">
          <div className="panel">
            <div className="pane1-body">
              {/* 注册路由 */}
              {/* <BrowserRouter> */}
              <Routes>
                <Route path="/about" caseSensitive element={<About></About>}></Route>
                <Route path="/home" element={<Home></Home>}></Route>
                <Route path="/" element={<Navigate to="/about"></Navigate>}></Route>
              </Routes>
              {/* </BrowserRouter> */}
            </div>
          </div>
        </div>
      </div>
    </div>
  )
}
